/**
 * 
 */
package com.example.rebbitmqdelayTest;
import javax.validation.Valid;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.example.rabbitmqTest.BaseResponse;
import com.example.rabbitmqTest.Status;  
/**
 * 订单交易记录controller 
 * @author yanglei
 * 2018年1月15日
 */
@Controller
@RequestMapping("/order")
public class OrderTradeRecordController {  
  
    private static final Logger log= LoggerFactory.getLogger(OrderTradeRecordController.class);  
  
  
    @Autowired  
    private OrderTradeRecordService orderTradeRecordService;  
  
    /** 
     * 创建用户下单记录 
     * @param requestData 
     * @param bindingResult 
     * @return 
     * @throws Exception 
     */  
    @SuppressWarnings("rawtypes")
	@RequestMapping(value = "/create",method = RequestMethod.POST)  
    public BaseResponse createRecord(@Valid OrderTradeRecordRequest requestData, BindingResult bindingResult) throws Exception{  
        if (bindingResult.hasErrors()){  
            return new BaseResponse(new Status());  
        }  
        BaseResponse response=new BaseResponse(new Status());  
        try {  
            orderTradeRecordService.createTradeRecord(requestData);  
        }catch (Exception e){  
            log.error("用户下单记录异常：{} ",requestData,e.fillInStackTrace());  
            return new BaseResponse(new Status());  
        }  
        return response;  
    }  
  
  
}  